package com.xli.mis.datasource.entity.mapper;

import com.xli.mis.datasource.entity.DataSource;
import com.xli.mis.datasource.entity.dto.DataSourceAddDTO;
import com.xli.mis.datasource.entity.dto.DataSourceUpdateDTO;
import com.xli.mis.datasource.entity.vo.DataSourceVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;


@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface IDataSourceMapper {

    IDataSourceMapper INSTANCE = Mappers.getMapper(IDataSourceMapper.class);

    @Mappings({
            @Mapping(source = "dsType", target = "ds_type"),
            @Mapping(source = "dsName", target = "ds_name"),
            @Mapping(source = "orderNum", target = "order_num")
    })
    DataSource toEntity(DataSourceAddDTO dataSourceAddDTO);

    @Mappings({
            @Mapping(source = "dsType", target = "ds_type"),
            @Mapping(source = "dsName", target = "ds_name"),
            @Mapping(source = "orderNum", target = "order_num")
    })
    DataSource toEntity(DataSourceUpdateDTO dataSourceUpdateDTO);

    @Mappings({
            @Mapping(source = "ds_type", target = "dsType"),
            @Mapping(source = "ds_name", target = "dsName"),
            @Mapping(source = "order_num", target = "orderNum")
    })
    DataSourceVO toVO(DataSource dataSource);
}
